from translate import Translator

def translate_strings(strings):
    """
    翻译字符串数组
    :param strings: 要翻译的字符串列表
    :return: 翻译结果列表
    """
    translator = Translator(to_lang="zh")
    results = []
    
    for text in strings:
        if text.strip():  # 跳过空字符串
            translation = translator.translate(text.strip())
            print(f"原文: {text} -> 翻译: {translation}")
            results.append(translation)
    
    return results

# 示例使用
if __name__ == "__main__":
    test_strings = [
        "Hello, world!",
        "How are you?",
        "This is a test."
    ]
    
    translations = translate_strings(test_strings)
    print("\n最终翻译结果:")
    for i, (orig, trans) in enumerate(zip(test_strings, translations)):
        print(f"{i+1}. {orig} -> {trans}")